package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException, ClassNotFoundException {
        //获取该类的对象
        Class c = Class.forName("reflect.Person");
        //获取指定类型的构造器
        Constructor con = c.getConstructor(String.class,int.class);
        String name=c.getName();

        //使用构造器创建实例化对象
        Object o = con.newInstance("李四",56);
        System.out.println(o);
    }
}
